package com.talent.jiwen.teacher;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.ImageView;
import android.widget.TextView;

import com.talent.jiwen.R;
import com.talent.jiwen.base.BaseFragment;
import com.zhy.adapter.recyclerview.CommonAdapter;
import com.zhy.adapter.recyclerview.base.ViewHolder;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

public class TeacherListFragment extends BaseFragment {
    @BindView(R.id.advertIv)
    ImageView advertIv;
    @BindView(R.id.famousRecycleView)
    RecyclerView famousRecycleView;
    @BindView(R.id.recommendRecycleView)
    RecyclerView recommendRecycleView;

    private List<String> famousTeacherList = new ArrayList<>();
    private List<String> recommendList = new ArrayList<>();

    @Override
    protected void initData() {

        advertIv.setImageResource(R.mipmap.bg_teacher_advert);

        famousTeacherList.clear();
        for (int i =  0 ; i < 10 ; i++){
            famousTeacherList.add("老师" + i);
        }
        LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
        layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
        famousRecycleView.setLayoutManager(layoutManager);
        famousRecycleView.setAdapter(new CommonAdapter<String>(getContext() , R.layout.item_famous_teacher , famousTeacherList){
            @Override
            protected void convert(ViewHolder holder, String s, int position) {
                ImageView  teacherIv  = holder.getView(R.id.teacherIv);
                teacherIv.setImageResource(R.mipmap.iv_teacher_test);

                TextView nameTv = holder.getView(R.id.nameTv);
                nameTv.setText(s);
            }
        });


        recommendList.clear();
        for (int i =  0 ; i < 10 ; i++){
            recommendList.add("老师" + i);
        }

        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
        recommendRecycleView.setLayoutManager(linearLayoutManager);

        recommendRecycleView.setHasFixedSize(true);
        recommendRecycleView.setNestedScrollingEnabled(false);

        recommendRecycleView.setAdapter(new CommonAdapter<String>(getContext() , R.layout.item_recommend_teacher , recommendList){
            @Override
            protected void convert(ViewHolder holder, String s, int position) {
                ImageView teacherIv =  holder.getView(R.id.teacherIv);
                TextView nameTv = holder.getView(R.id.nameTv);
                teacherIv.setImageResource(R.mipmap.iv_teacher_test);
                nameTv.setText(s);
            }
        });



    }

    @Override
    protected int provideContentViewId() {
        return R.layout.fragment_teacher_list;
    }

}
